Skip to content

BEEFY Consensus Client#553

Draft
dharjeezy wants to merge 25 commits intomainfrom
dami/beefy-consensus-client
Draft

BEEFY Consensus Client#553
dharjeezy wants to merge 25 commits intomainfrom
dami/beefy-consensus-client

Conversation

@dharjeezy
Copy link
Copy Markdown
Contributor

@dharjeezy dharjeezy commented Oct 9, 2025

This pull request introduces the ismp-beefy pallet, a consensus client for ISMP designed to verify Polkadot's BEEFY finality proofs. This implementation allows ISMP to process consensus updates from BEEFY, making it possible to trustlessly verify state commitments.

@seunlanlege
Copy link
Copy Markdown
Member

seunlanlege commented Oct 9, 2025

Looks like a great start, lets get tests

@seunlanlege seunlanlege changed the title Beefy Consensus Client BEEFY Consensus Client Oct 10, 2025
@dharjeezy dharjeezy requested a review from seunlanlege October 15, 2025 09:49
…/beefy-consensus-client

# Conflicts:
#	Cargo.toml
#	modules/pallets/testsuite/Cargo.toml
#	modules/pallets/testsuite/src/runtime.rs
verify fraud proof
fix tests
@dharjeezy dharjeezy requested a review from seunlanlege January 27, 2026 22:55
type Hash = [u8; 32];

fn hash(data: &[u8]) -> Self::Hash {
keccak256(data)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be generic

let mut data = [0u8; 64];
data[..32].copy_from_slice(left);
data[32..].copy_from_slice(right);
Ok(keccak256(&data))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines +79 to +80
let (state, heads_root) = verify_mmr_update_proof::<H>(trusted_state, proof.relay)?;
Ok((state.encode(), heads_root))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing parachain header verification

Comment on lines +137 to +144
println!("\n======= VERIFIER DEBUG =======");
let target_root = if is_current_authorities {
trusted_state.current_authorities.keyset_commitment
} else {
trusted_state.next_authorities.keyset_commitment
};
println!("Target Merkle Root: {:?}", H256::from(target_root));
println!("Verifier-side calculated authority leaf hashes:");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove println

Comment on lines +149 to +154
let k256_sig = K256Signature::from_slice(&sig.signature[0..64])
.map_err(|_| Error::InvalidSignatureFormat)?;

let recovered_verifying_key =
VerifyingKey::recover_from_prehash(commitment_hash.as_ref(), &k256_sig, recovery_id)
.map_err(|_| Error::FailedToRecoverPublicKey)?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make generic

Comment on lines +126 to +131
if !Parachains::<T>::contains_key(para_header.para_id) {
Err(Error::Custom(format!(
"Parachain with id {} not registered",
para_header.para_id
)))?
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip instead

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also why are we using ismp_parachain storage?

Comment on lines +242 to +248
#[derive(Encode)]
struct CanonicalMmrLeaf {
version: MmrLeafVersion,
parent_number_and_hash: (u32, H256),
beefy_next_authority_set: BeefyAuthoritySet<H256>,
leaf_extra: H256,
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this in substrate already?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't know if we need this, since we simply use the client in the outbound proofs pallet

@dharjeezy dharjeezy requested a review from seunlanlege April 6, 2026 09:02
Comment on lines +144 to +145
/// The k-index of the leaf, used in MMR calculations.
pub k_index: u32,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

Ok((new_state.encode(), verified_headers))
}

fn build_sp1_public_inputs<H: Keccak256>(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use alloy sol! macro?

pub parachains: Vec<ParachainHeader>,

/// Proof for parachain header inclusion in the parachain headers root
pub proof: Vec<Vec<(usize, [u8; 32])>>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is used in solidity

@seunlanlege
Copy link
Copy Markdown
Member

Oh i think we want to keep the ismp beefy client, just not the pallet

@dharjeezy dharjeezy requested a review from seunlanlege April 6, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants